var path = require('path');
var webpack = require('webpack');
/*
html-webpack-plugin插件，webpack中生成HTML的插件，
可以将打包好的文件动态加载到html中
 */
var HtmlWebpackPlugin = require('html-webpack-plugin');

//定义文件夹路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH,'app');
var BUILD_PATH = path.resolve(ROOT_PATH,'build');
var CSS_PATH = path.resolve(ROOT_PATH,'css');

module.exports = {
    entry: APP_PATH ,
    output: {
        filename: 'bundle.js',
        path: BUILD_PATH
    },
    module: {
        loaders: [
            {
                test: /\.js|\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    //添加两个presents使用这两种presets处理js或者jsx文件
                    //  presets : ['es2015','react']
                    presets: ['es2015','react']
                },
            },
            {
                test: /\.less$/,
                loader: ['style', 'css','less'],
                include: CSS_PATH
            },
       ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            title : 'Hello Webpack!'
        })
    ],
    //监听端口
    devServer : {
        contentBase : './',
        host : 'localhost',
        port : 3200,
        inline : true ,
        hot : true
    }
};